<section class="wrapper">
  <!-- page start-->
  <div class="row">
    <div class="col-lg-12">
      <section class="panel">
        <header class="panel-heading">
          修 改
        </header>
        <div class="panel-body">
          <form class="form-horizontal adminex-form" >
            <div class="form-group">
              <label class="col-sm-2 col-sm-2 control-label"><i class="bi_tian">*&nbsp</i>标题</label>
              <div class="col-sm-10">
                <input type="text" name="title" value="<%= @article.title %>" class="form-control" placeholder="请输入标题">
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-2 col-sm-2 control-label"><i class="bi_tian">*&nbsp</i>摘要</label>
              <div class="col-sm-10">
                <input type="text" name="abstract" value="<%= @article.abstract %>" class="form-control" placeholder="请输入摘要">
              </div>
            </div>
            <input type="text" class="show_content" hidden value="<%= @article.content %>">
            <div class="form-group">
              <label class="col-sm-2 col-sm-2 control-label"><i class="bi_tian">*&nbsp</i>内容</label>
              <div id="editor" class="col-sm-10">
                <div>
                </div>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-2 col-sm-2 control-label"><i class="bi_tian">*&nbsp</i>状态</label>
              <div class="col-sm-10">
                <select class="form-control" name="status">
                  <option value="1">可用</option>
                  <option value="2" <%= @article.status == 2 ? 'selected' : '' %>>停用</option>
                </select>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-2 col-sm-2 control-label"></label>
              <div class="col-sm-10">
                <button type="button" class="btn btn-primary" id="submit_data" data-url="/admin/articles/<%= @article.id %>">提交</button>
              </div>
            </div>
          </form>
        </div>
      </section>
    </div>
  </div>
</section>
<% content_for :js do %>
  <!-- 注意， 只需要引用 JS，无需引用任何 CSS ！！！-->
  <script type="text/javascript" src="/js/wangEditor.min.js"></script>
  <script type="text/javascript" charset="utf-8">
      var E = window.wangEditor;
      var editor = new E('#editor');
      editor.customConfig.uploadImgServer = '/admin/articles/upload';
      editor.create();
      $('#submit_data').click(function () {
          var _this = $(this);
          var url = _this.attr('data-url');
          var data = {};
          data['title'] = $('input[name=title]').val();
          data['abstract'] = $('input[name=abstract]').val();
          data['content'] = editor.txt.html();
          data['status'] = $('select[name=status]').val();
          doRequest(_this,url,'PUT',data);
      });
      window.onload = function () {
          var content = $('.show_content').val();
          editor.txt.html(content);
      }
  </script>
<% end %>